 #!/usr/bin/env bash

PW=/etc/passwd

#kylin_user01: 不创建家目录、UID：4000、不创建同名组、登陆shell为/sbin/nologin非交付shell
UID_user01=`awk -F: '$1=="kylin_user01"{print $3}' $PW`
SHELL_user01=`awk -F: '$1=="kylin_user01"{print $NF}' $PW`
echo $SHELL_user01
if [ ! -d /home/kylin_user01 ] && [ $UID_user01 -eq 4000 ] && [ `grep -c kylin_user01 /etc/group` -eq 0 ];then
	echo true
else
	echo false
fi

# kylin_user02：设置为系统用户，家目录为/home/kylin_user02 ，附加组为root组
UID_user02=`awk -F: '$1=="kylin_user02"{print $3}' $PW`

if egrep "^root" /etc/group|grep "kylin_user02" >/dev/null 2>&1;then
	if [ $UID_user02 -lt 1000 ];then
		echo true
	else
		echo false
	fi
else
	echo false
fi


#kylin_user03：用户过期时间为"2021-9-30"；密码过期时间为7天；
if [ `chage -l kylin_user03 |grep "Account expires"|grep -c "Sep 30, 2021"` -gt 0 ];then
      echo true
else    
        echo false
fi      




#修改用户：games
#- 修改用户等了shell为/bin/bash
#- 修改用户注释为“user modify test”
GAME_decs=`awk -F: '$1=="games"{print $5}' $PW`
GAME_shell=`awk -F: '$1=="games"{print $NF}' $PW`
echo $GAME_decs
echo $GAME_shell
#if [ "$GAME_decs" == "user modify test" ] && [ "$GAME_shell" == "/bin/bash" ];then
#	echo true
#else
#	echo false
#fi

#删除用户:lp
if egrep "^lp" $PW >/dev/null 2>&1;then
	echo true
else
	echo false
fi